package me.a01immutable;

import java.util.Map;
import java.util.Set;

public class ImmutableDemo3 {
    public static void main(String[] args) {
        //创建Map的不可变集合
        Map<String, String> map = Map.of("张三", "浙江", "李四", "江苏", "王五", "上海");
        Set<String> keys = map.keySet();

        for (String key : keys) {
            String value = map.get(key);
            System.out.println(key + " = " + value);
        }
        System.out.println("----------------------------");

        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + " = " + value);
        }
    }

}
